define(function(require, exports, module) {
	"require:nomunge,exports:nomunge,module:nomunge";

	var app = require('mokit/app');
	var ProjectListView = require('../views/ucenter-project-subtask-info');
	var commonUtils = require('../common/utils');
	var UPsubtask = require('../models/UPsubtask');

	/**
	 * 社友录页面控制器
	 */
	return app.controller.create({
		isSetting: true,
		/**
		 * 默认action
		 */
		index: function(context) {
			var self = this;
			//UPsubtask.getInfo(context.routeData.id, function() {
				self.setView(new ProjectListView({
					model: UPsubtask
				}));
			//});
		},
		iWantJoin: function(context) {
			var self = this;
			var model = context.view.getNewProjectInfo(context);
			projectModel.theProject.projectName = model.projectName;
			projectModel.theProject.projectInfo = model.projectInfo;
			projectModel.submitProject(function(err) {
				if (err) {
					self.rootView.toast(context, err);
				} else {
					self.go(context, "/project/done", "/project/new");
				}
			});
		},
		addPosition: function(context) {
			var self = this;
			var info = context.view.getNewPositionInfo(context);
			projectModel.addPosition(info, function(err) {
				if (err) {
					self.rootView.toast(context, err);
				} else {
					context.view.closeAddPosition(context, false, function() {
						context.view.positionList.render();
						context.view.clearPostionInput(context);
					});
				}
			});
		}
	});

});